import logo from './logo.svg';
import './App.css';
import React from 'react';
function Weclome(props) {
  return <h1>hello,{props.name}</h1>
}

class Clock extends React.Component {
  constructor(props) {
    super(props);
    this.state = {date: new Date()}
  }

  componentDidMount() {
    this.timerID = setInterval(()=> this.tick(), 1000)
  }
  componentWillUnmount() {
    clearInterval(this.timerID)
  }
  tick() {
    this.setState({date: new Date()})
  }
  render() {
    return (
      <div>
        <h1>Hello, world!</h1>
        <h2>It is {this.state.date.toLocaleTimeString()}</h2>
      </div>
    )
  }
}

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <Weclome name="LiSa1"/>
        <Weclome name="LiSa2"/>
        <Weclome name="LiSa3"/>
        <Clock/>,
      </header>
    </div>
  );
}

export default App;
